using System;
using System.Web.UI;
using ElevatorSpeeches.Framework;

namespace ElevatorSpeeches.UI.WebForms
{
    public partial class CreateSpeech : Page
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Page.Title= "Create New Topic " + Constants.WEBSITE_TITLE_POSTFIX;
        }

        protected void Create_Speech(object sender, EventArgs e)
        {
            SpeechTopic _SpeechTopic = new SpeechTopic { Title = Title.Text };

            if (_SpeechTopic.IsValid())
            {                
                _SpeechTopic.Save();                
                Response.Redirect("~/topics/" + _SpeechTopic.PrettyUrl);
            }
            else
            {
                ValidationDisplay.ErrorMessages = _SpeechTopic.AllErrorMessages;
            }
        }
    }
}
